﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;
using DTO;

namespace GUI
{
    public partial class frmXemDSPhieuTra : Form
    {
        public frmXemDSPhieuTra()
        {
            InitializeComponent();
        }

        private void frmXemDSPhieuTra_Load(object sender, EventArgs e)
        {
            dgvDSPhieuTra.Rows.Clear();
            LayDanhSachPTH();
            dgvChiTiet.Rows.Clear();
            LayDanhSachChiTietPTH();
        }

        private void LayDanhSachPTH()
        {
            int stt = dgvDSPhieuTra.Rows.Count;
            PhieuTraHangBUS pthBUS = new PhieuTraHangBUS();
            List<PhieuTraHangDTO> listPTH = pthBUS.LayDanhSachPTH();
            for (int i = 0; i < listPTH.Count; i++)
            {
                stt += 1;
                dgvDSPhieuTra.Rows.Add(stt, listPTH[i].MaPhieuTra, listPTH[i].MaNhaCungCap, listPTH[i].NgayTra, listPTH[i].TongTien);
            }
        }
        private void LayDanhSachChiTietPTH()
        {
            int stt = dgvChiTiet.Rows.Count;
            ChiTietPhieuTraHangBUS ctpthBUS = new ChiTietPhieuTraHangBUS();
            List<ChiTietPhieuTraHangDTO> listCTPTH = ctpthBUS.DanhSachChiTietPTH();
            for (int i = 0; i < listCTPTH.Count; i++)
            {
                stt += 1;
                dgvChiTiet.Rows.Add(stt, listCTPTH[i].MaCTPhieuTra, listCTPTH[i].MaPhieuTra, listCTPTH[i].MaMatHang, listCTPTH[i].MaXuatXu, listCTPTH[i].MaDonViTinh, listCTPTH[i].MaLoiMatHang, listCTPTH[i].SoLuong, listCTPTH[i].GiaNhap);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
